package com.relax.no_xml.config;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.relax.no_xml.aop.AopService;
import com.relax.no_xml.aop.LogAspects;
import com.relax.no_xml.aop.NormalService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;
import java.beans.PropertyVetoException;

@Configuration
@ComponentScan("com.relax.no_xml.shiw")
public class ShiwuConfig {

	@Bean
	public AopService aopService(){
		return new AopService();
	}



	@Bean
	public DataSource dataSource() throws Exception {
		ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
		comboPooledDataSource.setUser("root");
		comboPooledDataSource.setPassword("root123");
		comboPooledDataSource.setDriverClass("com.mysql.jdbc.Driver");
		comboPooledDataSource.setJdbcUrl("jdbc:mysql://localhost:3306/pqs");
		return comboPooledDataSource;
	}


	 @Bean
	public JdbcTemplate jdbcTemplate() throws Exception {
		 JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource());
		 return jdbcTemplate;
	 }
}
